"""
@version:python3
@author:ll
@file:04-QWidget-层级关系-案例.py
@time:2022/2/11 20:41
"""
from PyQt5.Qt import *


class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("")
        self.resize(500, 500)
        self.setup_ui()

    def setup_ui(self):  # 添加子控件以及子控件的配置操作
        pass
    def mousePressEvent(self, evt):
        local_x = evt.x()
        local_y = evt.y()
        sub_widget = self.childAt(local_x,local_y)
        if sub_widget:
            sub_widget.raise_()

if __name__ == "__main__":
    import sys

    app = QApplication(sys.argv)
    window = Window()
    label1 = QLabel(window)
    label1.setText("标签1")
    label1.resize(200,200)
    label1.setStyleSheet("background-color:red")

    label2 = QLabel(window)
    label2.setText("标签2")
    label2.resize(200, 200)
    label2.move(100,100)
    label2.setStyleSheet("background-color:green")

    window.show()

    sys.exit(app.exec_())
